public class Scan{
    

     int shape[][][]=new int[19][19][5];
  
     
     void scan(int chesspad[][],int colour){
        int i,j;

        for(i=0;i<=18;i++)
             for(j=0;j<=18;j++)
                  if(chesspad[i][j]==0){
                           int m=i,n=j;
                        
                        
                                   
                                
                             
                                   while(n-1>=0&&chesspad[m][--n]==colour){
                                           shape[i][j][0]++;
                                          }
                                   n=j;
                                   while(n+1<=18&&chesspad[m][++n]==colour){
                                          shape[i][j][0]++;
                                          }
                                         
                                  
                                   n=j;
                                   while(m-1>=0&&chesspad[--m][n]==colour){
                                           shape[i][j][1]++;
                                          }
   				   m=i;
                                   while(m+1<=18&&chesspad[++m][n]==colour){
                                           shape[i][j][1]++;
                                          }	
                                  
                                        
                                   m=i;
                                   while(m-1>=0&&n+1<=18&&chesspad[--m][++n]==colour){
                                           shape[i][j][2]++;
                                           }
          		           m=i;n=j; 
				   while(m+1<=18&&n-1>=0&&chesspad[++m][--n]==colour){
                                            shape[i][j][2]++;
                                           }
          		          
                                   m=i;n=j; 
                                  
				   while(m-1>=0&&n-1>=0&&chesspad[--m][--n]==colour){
                                           shape[i][j][3]++;
                                           }
          		           m=i;n=j; 
				   while(m+1<=18&&n+1<=18&&chesspad[++m][++n]==colour){
                                           shape[i][j][3]++;
                                           }
      
       

   } 
       
 }     

}          		                                                   
        
